Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tls/http: add certificate chain setters #1125

Merged
merged 1 commit into from
May 23, 2024

Conversation

maximilianfridrich
Copy link
Contributor

The current setters (e.g. tls_set_certificate) only allow single certificates to be set. Now the whole chain can be set.

@maximilianfridrich maximilianfridrich force-pushed the tls_cert_chain_setters branch 2 times, most recently from 17fe5ad to 4cc622b Compare May 22, 2024 07:47
@@ -169,6 +169,9 @@ int http_client_set_cert(struct http_cli *cli, const char *path);
int http_client_set_certpem(struct http_cli *cli, const char *pem);
int http_client_set_key(struct http_cli *cli, const char *path);
int http_client_set_keypem(struct http_cli *cli, const char *pem);
int http_client_use_chain(struct http_cli *cli, const char *path);
int http_client_use_chainpem(struct http_cli *cli, const char *chain,
int len_chain);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use size_t len_chain which is consistant with the API ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to prevent the cast from size_t to int when calling BIO_new_mem_buf, but consistency makes sense. Done.

if (!cli || !cli->tls)
return EINVAL;

err = tls_set_certificate_chain_pem(cli->tls, chain, len_chain);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use C99 style declare and assign here ... int err = ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

X509 *cert = NULL;
X509 *leaf_cert = NULL;
int err = ENOMEM;
long ok = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to move the declaration of some of these variables further down, to the assignment ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@alfredh
Copy link
Contributor

alfredh commented May 23, 2024

In general it looks good. some minor comments ...

@maximilianfridrich
Copy link
Contributor Author

Thank you for the review! @alfredh

@alfredh alfredh merged commit d021190 into baresip:main May 23, 2024
37 checks passed
@maximilianfridrich maximilianfridrich deleted the tls_cert_chain_setters branch May 28, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants